<template>
  <div class="nav-crumbs">
    <div v-if="modelName" class="model-title">
      <img src="../assets/icon/icon-back.png" @click="goBack" />
      <span class="model-name">{{modelName}}</span>
    </div>
    <div v-else class="overview-title">总览</div>
    <div class="search" v-if="!modelName">
      <input class="search-input" v-model="keywork" placeholder="请输入任务名称" v-on:keyup.enter="searchHandle"/>
      <img class="icon-search" src="../assets/icon/icon-search.png" @click="searchHandle"/>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    modelName: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      keywork: ''
    }
  },
  methods: {
    goBack() {
      this.$router.push({name:'main'})
    },
    searchHandle() {
      this.$emit('search', this.keywork)
    }
  },
  watch: {
    $route() {
      this.keywork = ''
    }
  }
}
</script>

<style lang="scss" scoped>
.nav-crumbs{
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 58px;
  background: #F9F9F9;
  box-shadow: 0px 3px 8px 0px rgba(122, 128, 159, 0.1);
  z-index: 1;
}

.model-title{
  margin-left: 50px;
}

.overview-title,
.model-name{
  font-size: 26px;
  color: #111434;
}

.overview-title{
  margin-left: 64px;
  text-decoration: underline;
}

.model-name{
  margin-left: 50px;
}

.search{
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 270px;
  height: 34px;
  margin-right: 15px;
  padding-left: 18px;
  background: #F9F9F9;
  border: 1px solid #C6CCD8;
  border-radius: 17px;
  overflow: hidden;
  cursor: pointer;

  .search-input{
    flex: 1;
    display: block;
    height: 100%;
    width: 100%;
    line-height: 32px;
    font-size: 16px;
    color: #A8ADB7;
    border: none;
    outline: none;
    background-color: transparent;

    &::placeholder{
      font-size: 16px;
      color: #A8ADB7;
    }

    &:focus{
      border: none;
      outline: none;
    }
  }

  .icon-search{
    margin: 0 23px 0 10px;
  }
}
</style>